package com.cxs.service.impl;

import com.cxs.mapper.QuestionsMapper;
import com.cxs.model.Questions;
import com.cxs.model.QuestionsExample;
import com.cxs.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
 * @Author:cxs
 * @Date:2021/10/3  15:50
 * @Version 1.0
 * @Motto:放下杂念,只为迎接明天更好的自己
 * */
@Service
public class QuestionServiceImpl implements QuestionService {
    @Autowired
    private QuestionsMapper questionsMapper;

    @Override
    public List<Questions> list() {
        QuestionsExample example = new QuestionsExample();
        example.setOrderByClause("last_modified desc");
        return questionsMapper.selectByExample(example);
    }

    @Override
    public Questions detail(Integer id) {
        return questionsMapper.selectQuesAndAns(id);
    }

    @Override
    public int add(Questions questions) {
        return questionsMapper.insertSelective(questions);
    }
}
